package org.waigua.moka.dto;

import java.util.HashMap;
import java.util.Map;

import org.waigua.moka.constant.ApiConstant;

public abstract class ApiDto
{
	@Override
	public String toString()
	{
		return "ApiDto [host=" + host + ", openCardChip=" + openCardChip + ", v=" + v + ", phpp=" + phpp + ", phpl="
				+ phpl + ", pvc=" + pvc + ", pvb=" + pvb + ", sid=" + sid + ", body=" + body + ", charSet=" + charSet
				+ ", method=" + method + ", contentType=" + contentType + ", userAgent=" + userAgent
				+ ", contentLength=" + contentLength + ", refer=" + refer + ", flashVersion=" + flashVersion
				+ ", accept=" + accept + ", acceptEncoding=" + acceptEncoding + ", header=" + header + "]";
	}

	private String host;
	private String openCardChip = "1";
	private String v;
	private String phpp = "ANDROID";
	private String phpl = "ZH_CN";
	private String pvc;
	private String pvb;
	private String sid;
	private String body;
	private String charSet = "UTF-8";

	private String method = "POST";
	private String contentType = "application/x-www-form-urlencoded";
	private String userAgent = "Mozilla/5.0 (Android; U; zh-CN) AppleWebKit/533.19.4 (KHTML, like Gecko) AdobeAIR/4.0";
	private int contentLength = 0;
	private String refer = "app:/assets/CardMain.swf";
	private String flashVersion = "12,0,0,68";
	private String accept = "text/xml, application/xml, application/xhtml+xml, text/html;q=0.9, text/plain;q=0.8, text/css, image/png, image/jpeg, image/gif;q=0.8, application/x-shockwave-flash, video/mp4;q=0.9, flv-application/octet-stream;q=0.8, video/x-flv;q=0.7, audio/mp4, application/futuresplash, */*;q=0.5";
	private String acceptEncoding = "deflate, gzip";
	private Map<String, String> header;

	protected ApiDto(String host, String v, String pvc, String pvb, String sid)
	{
		this.host = host;
		this.v = v;
		this.pvc = pvc;
		this.pvb = pvb;
		this.sid = sid;
	}

	public static ApiDto buildApiDto(String host, String v, String pvc, String pvb, String sid)
	{
		return new InnerApiDto(host, v, pvc, pvb, sid);
	}

	public static ApiDto buildApiDto()
	{
		return new InnerApiDto(ApiConstant.HOST, String.valueOf(ApiConstant.getV()), ApiConstant.PVC, ApiConstant.PVB,
				ApiConstant.SID);
	}

	public static ApiDto buildEditUserMapStagesApiDto(String host, String v, String pvc, String pvb, String sid,
			Map<String, String> params)
	{
		return new ContentApiDto(host, v, pvc, pvb, sid, params);
	}

	public static ApiDto buildPostContentApiDto(Map<String, String> params)
	{
		return new ContentApiDto(ApiConstant.HOST, String.valueOf(ApiConstant.getV()), ApiConstant.PVC,
				ApiConstant.PVB, ApiConstant.SID, params);
	}

	public Map<String, String> getHeaderMap()
	{
		if (header != null)
		{
			return header;
		}
		Map<String, String> map = new HashMap<String, String>();
		map.put("Accept-Encoding", acceptEncoding);
		map.put("Cookie", "_sid=" + sid);
		map.put("Accept", accept);
		map.put("User-agent", userAgent);
		map.put("x-flash-version", flashVersion);
		map.put("Refer", refer);
		map.put("Content-Length", String.valueOf(contentLength));
		map.put("Content-Type", contentType);
		header = map;
		return header;
	}

	public String getCharSet()
	{
		return charSet;
	}

	public void setBody(String body)
	{
		this.body = body;
	}

	public String getBody()
	{
		return body;
	}

	public String getHost()
	{
		return host;
	}

	public void setHost(String host)
	{
		this.host = host;
	}

	public String getOpenCardChip()
	{
		return openCardChip;
	}

	public void setOpenCardChip(String openCardChip)
	{
		this.openCardChip = openCardChip;
	}

	public String getV()
	{
		return v;
	}

	public void setV(String v)
	{
		this.v = v;
	}

	public String getPhpp()
	{
		return phpp;
	}

	public void setPhpp(String phpp)
	{
		this.phpp = phpp;
	}

	public String getPhpl()
	{
		return phpl;
	}

	public void setPhpl(String phpl)
	{
		this.phpl = phpl;
	}

	public String getPvc()
	{
		return pvc;
	}

	public void setPvc(String pvc)
	{
		this.pvc = pvc;
	}

	public String getPvb()
	{
		return pvb;
	}

	public void setPvb(String pvb)
	{
		this.pvb = pvb;
	}

	public String getSid()
	{
		return sid;
	}

	public void setSid(String sid)
	{
		this.sid = sid;
	}

	public String getMethod()
	{
		return method;
	}

	public void setMethod(String method)
	{
		this.method = method;
	}

	public String getContentType()
	{
		return contentType;
	}

	public void setContentType(String contentType)
	{
		this.contentType = contentType;
	}

	public String getUserAgent()
	{
		return userAgent;
	}

	public void setUserAgent(String userAgent)
	{
		this.userAgent = userAgent;
	}

	public int getContentLength()
	{
		return contentLength;
	}

	public void setContentLength(int contentLength)
	{
		this.contentLength = contentLength;
	}

	public String getRefer()
	{
		return refer;
	}

	public void setRefer(String refer)
	{
		this.refer = refer;
	}

	public String getFlashVersion()
	{
		return flashVersion;
	}

	public void setFlashVersion(String flashVersion)
	{
		this.flashVersion = flashVersion;
	}

	public String getAccept()
	{
		return accept;
	}

	public void setAccept(String accept)
	{
		this.accept = accept;
	}

	public String getAcceptEncoding()
	{
		return acceptEncoding;
	}

	public void setAcceptEncoding(String acceptEncoding)
	{
		this.acceptEncoding = acceptEncoding;
	}

}
